package com.zengqingfa.basic.mapstruct;

import com.zengqingfa.basic.mapstruct.dto.Car;
import com.zengqingfa.basic.mapstruct.dto.CarDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper
public interface CarConverter {

    // 实例
    CarConverter INSTANCE = Mappers.getMapper(CarConverter.class);

    /**
     * 属性名一样的，会自动映射并填充，属性名不一样的用下面这个 @Mapping 注解，定义映射关系
     * source 为数据来源，target为要填充的目标属性
     */
    @Mapping(source = "wheel", target = "whe")
    CarDto carToDto(Car car);
}

